<?php

/**
 * Created by Sublime.
 * User: yinni
 * Date: 2017/12/01 14:03
 */
namespace App\Http\Controllers\Admin\Alarmanswer;

use Log;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Services\Admin\AlarmanswerService;
use App\Http\Requests\Admin\UserRequest;
use \App\Http\Controllers\Admin\BaseController;

/**
 * 根据实时监测临界值进行报警响应
 * Class AlarmController
 * @package App\Http\Controllers\Admin\Alarmanswer
 */
class AlarmanswerController extends BaseController
{
    protected $service;

    public function __construct(AlarmanswerService $service)
    {
        parent::__construct();
        $this->service = $service;
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $result = $this->service->index();
        return request()->ajax() ? $result : view('themes.admin.alarmanswer.index')->with($result);
    }

    public function alltimeinfo() {
        $alltime_data = $this->service->ajaxJsonData();
        // $json_alltime_data = responce()->json($alltime_data);
        // dump($alltime_data);die;
        // Log::info('错误提示信息');
        // die();
        return $alltime_data;
    }

    // // 暂时测试，待整合至servcie中
    // // 目前逻辑为判断所有超越警报值的数据
    public function cancel(){
        $result = $this->service->ajaxAlarmCancel();
        return $result;
    }


}